home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)TA
/
(A)TAL.ADF
/
Basic_Progs
/
Civil_War
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1986-11-06
|
13KB
|
455 lines
PRINT TAB(26) "CIVIL WAR" :PRINT
PRINT TAB(15) "COURTESY OF CREATIVE COMPUTING MORRISTOWN, NEW JERSEY "
PRINT :PRINT :PRINT
'ORIGINAL GAME DESIGN...CRAN, GOODIE, HIBBARD LEXINGTON H. S.
'MODIFICATIONS...G. PAUL, R. HESS (TIES),1973
'ADAPTED TO `AMY' BY BILL ELLIOTT (BAUG),1988
'COLOUR SCHEME FROM ARTICLE BY JOHN BOS (BAUG NEWSLETTER 4)
GOSUB SETSCREEN
DIM s(4),c$(14),m1(14),m2(14),c1(14),c2(14),m(14)
'UNION INFO ON LIKELY CONFEDERATE STATEGY
s(1)=25:s(2)=25:s(3)=25:s(4)=25
'READ HISTORICAL DATA.
FOR d = 1 TO 14
READ c$(d),m1(d),m2(d),c1(d),c2(d),m(d)
NEXT d
LET d = RND(-1)
PRINT
PRINT "Do you want instructions";
110 INPUT x$
IF x$ = "yes" THEN 160
IF x$ = "no" THEN 370
PRINT "yes or no";
GOTO 110
160 PRINT
PRINT " This is a Civil War simulation."
PRINT "To play, type a response when the computer asks."
PRINT "Remember that all factors are interrelated and that your"
PRINT "responses could change history. Facts and figures used are"
PRINT "based on the actual occurence. Most battles tend to result"
PRINT "as they did in the civil war, but it all depends on you!!"
PRINT " The object of the game is to win as many battles as ";
PRINT "possible."
PRINT " Your choices for defensive strategy are:"
PRINT
PRINT " (1) Artillery attack"
PRINT " (2) Fortification against frontal attack"
PRINT " (3) Fortification against flanking maneuvres"
PRINT " (4) Falling back "
PRINT
PRINT " Your choices for offensive strategy are:"
PRINT
PRINT " (1) Artillery attack"
PRINT " (2) Frontal attack"
PRINT " (3) Flanking maneuvres"
PRINT " (4) Encirclement"
PRINT " You may surrender by typing a `5' for your strategy"
370 PRINT
380 INPUT " Are there two generals present. (Answer yes or no) ";b$
IF b$ = "yes" THEN 430
IF b$ <> "no" THEN 380
PRINT:PRINT :PRINT " You are the Confederacy. Good Luck!"
430 LET d = 1
IF b$ <> "yes" THEN 460
LET d = 2
460 PRINT " Select a battle by typing a number from 1 to 14 on"
PRINT "request. Type any other number to end the simulation."
PRINT " A `0' brings back the exact previous battle situation"
PRINT "allowing you to replay it."
PRINT
PRINT "Note: A negative Food$ entry causes the program to
PRINT " use entries from the previous battle."
PRINT
PRINT "After requesting a battle, do you wish ";
PRINT "battle descriptions"
560 INPUT " Answer yes or no.";x$
IF x$ = "yes" THEN 600
IF x$ <> "no" THEN 560
600 l=0:w=0:r1=0:q1=0:N3=0:N4=0:p1=0:p2=0:t1=0:t2=0:f(2)=0:h(2)=0
b(2)=0:r2=0:q2=0:c6=0:f=0:wo=0:y=0:y2=0:u=0:u2=0
PRINT
PRINT
620 PRINT
PRINT
630 INPUT" Which battle do you wish to simulate";a
IF a <> 0 THEN 660
IF r <> 0 THEN 1140
660 IF a <= 0 THEN 2860
IF a >= 15 THEN 2860
LET c$ = c$(a)
LET m1 = m1(a)
LET m2 = m2(a)
LET c1 = c1(a)
LET c2 = c2(a)
LET m = m(a)
LET u = 0
'Inflation calc
LET i1 = 10 + (l-w)*2
LET i2 = l0 + (w-l)*2
'money available
LET d(1)=100*INT((m1*(100-i1)/2000)*(1+(r1-q1)/(r1+1))+0.5)
LET d(2) = 100*INT(m2*(100-i2)/2000+0.5)
IF b$<> "yes" THEN 1050
LET d(2)=100*INT((m2*(100-i2)/2000)*(1+(r2-q2)/(r2+1))+0.5)
1050 'men available
LET m5=INT (m1*(1+(p1-t1)/(m3+1)))
LET m6=INT (m2*(1+(p2-t2)/(m4+1)))
LET f1 = 5*m1/6
PRINT
PRINT
PRINT
PRINT
1100 PRINT " This is the battle of ";c$
IF x$ = "no" THEN 1150
IF a> 11 THEN 1130
ON a GOTO 3580,3620,3650,3690,3720,3750,3780,3800,3830,3860,3890
1130 ON a GOTO 3920,3950,3980
1140 PRINT c$" Instant replay"
1150 PRINT
PRINT " ","Confederacy"," Union"
PRINT "Men",m5,m6
PRINT "Money","$";d(1),"$";d(2)
PRINT "Inflation"," ";i1+15;"%"," ";12;"%"
PRINT
'only in printout is Confed inflation = i1 + 15%
'if two generals, input Confed first
FOR i = 1 TO d
IF b$ <> "yes"THEN 1260
IF i = 2 THEN 1260
PRINT " Confederate General---";
1260 INPUT " How much do you wish to spend for food.......";f
IF f >=0 THEN 1360
IF r1 <> 0 THEN 1330
PRINT " No previous entries
GOTO 1260
PRINT " Assume you want to keep the same allocations
PRINT
GOTO 1510
1360 LET f(i) = f
PRINT" -Salaries..";
INPUT h(i)
LET n = 1
IF h(i) <0 THEN 1490
1410 PRINT " -Ammunition";
INPUT b(i)
LET n = 2
IF b(i) <0 THEN 1490
PRINT
IF f(i)+h(i)+b(i)<= d(i) THEN 1510
PRINT " Think again! You have only $";d(i)
GOTO 1260
1490 PRINT " Negative values not allowed"
ON n GOTO 1360,1410
1510 IF b$ <> "yes" THEN 1550
IF i = 2 THEN 1550
PRINT " Union General---";
NEXT i
1550 FOR z = 1 TO d
IF b$ <> "yes" THEN 1620
ON z GOTO 1580,1600
1580 PRINT "Confederate ";
GOTO 1620
1600 PRINT " Union ";
'find morale
1620 LET o = ((2*f(z)^2+h(z)^2)/f1^2)
IF o<10 THEN 1660
PRINT " Morale is high!!!"
GOTO 1700
1660 IF o<5 THEN 1690
PRINT " Morale is fair."
GOTO 1700
1690 PRINT " Morale is poor!!"
1700 IF b$<>"yes" THEN 1760
LET o(z) = 0
NEXT z
LET o2 = o(2)
LET o = o(1)
PRINT " Confederate General---";
1760 '-Actual off/def Battle Situation
IF n <> 3 THEN 1800
PRINT "You are on the offensive"
GOTO 1840
1800 IF n <> 1 THEN 1830
PRINT " You are on the defensive..."
GOTO 1840
1830 PRINT " Both sides are on the offensive..."
1840 PRINT
' choose strategies
IF b$<> "yes" THEN 1910
FOR i = 1 TO 2
ON i GOTO 1890, 1920
1890 PRINT " Confederate stategy ";
1910 GOTO 1920
1920 INPUT " Your stategy ";y
IF ABS (y-3) < 3 THEN 1960
PRINT " Strategy ";y;"not allowed."
GOTO 1910
1960 IF b$ = "yes" THEN 2000
IF y = 5 THEN 2830
GOSUB 3110
GOTO 2170
2000 IF i = 2 THEN 2040
LET y1 = y
2020 PRINT " Union stategy ";
NEXT i
2040 LET y2 = y
LET y = y1
IF y2 = 5 THEN 2020
'Simulated losses-north
LET c6 = (2*c2/5)*(1+1/(2*(ABS(y2-y)+1)))
LET c6 = c6*(1.28+(5*m2/6)/(b(2)+1))
LET c6 = INT (c6*(1+1/o2)+0.5)
'if loss > men present, rescale losses
LET e2 = 100/o2
IF INT(c6+e2)< m6 THEN 2190
LET c6 = INT(13*m6/20)
LET e2 = 7*c6/13
LET u2 = 1
2170 'calculate simulated losses
PRINT
2190 PRINT :PRINT :PRINT :PRINT
PRINT " ","Confederacy","Union
LET c5 = (2*c1/5)*(1+1/(2*(ABS(y2-y)+1)))
LET c5 = INT(c5*(1+1/o)*(1.28+f1/(b(1)+1))+0.5)
LET e = 100/o
IF c5 + 100/o < m1*(1+(p1-t1)/(m3+1)) THEN 2270
LET c5 = INT (13*m1/20*(1+(p1-t1)/(m3+1)))
LET e = 7*c5/13
LET u = 1
2270 IF d = 1 THEN 2500
2280 PRINT "Casualties",c5,c6
PRINT "Desertions",INT(e),INT(e2)
PRINT
IF b$ = "yes" THEN 2530
PRINT " Compared to the actual casualties at ";c$
PRINT " Confederate:"INT(100*(c5/c1)+0.5)"% of the original"
PRINT " Union: "INT(100*(c6/c2)+0.5)"% of the original
PRINT
' Who won?
IF u <> 1 THEN 2380
IF u2 = 1 THEN 2460
2380 IF u = 1 THEN 2420
IF u2 = 1 THEN 2440
IF c5+e = c6 + e2 THEN 2460
IF c5+e < c6+e2 THEN 2440
2420 PRINT " The Union wins ";c$
GOTO 2600
2440 PRINT " The Confederacy wins ";c$
GOTO 2660
2460 PRINT " Battle outcome unresolved."
LET wo = wo + 1
IF a = 0 THEN 2790
GOTO 2680
2500 LET c6 = INT(17*c2*c1/(c5*20))
LET e2 = 5*o
GOTO 2280
2530 PRINT " Your casualties were "INT(100*(c5/c1)+0.5)% of
PRINT "the actual casualties at ";c$
PRINT
'find who won...
IF u = 1 THEN 2590
IF c5 +e< 17*c2*c1/(c5*20)+5*o THEN 2630
2590 PRINT " You lose ";c$
2600 IF a =0 THEN 2790
LET l = l+1
GOTO 2680
PRINT " You win ";c$
'Cumulative battle factors which alter historical
'resources available. If a replay don't update.
2660 IF a = 0 THEN 2790
LET w = w+1
2680 LET t1 = t1 +c5 +e
LET t2 = t2 +c6 +e2
LET p1 = p1 + c1
LET p2 = p2 + c2
LET q1 = q1 + (f(1)+ h(1) + b(1))
LET q2 = q2 + (f(2)+ h(2) + b(2))
LET r1 = r1 + m1*(100-i1)/20
LET r2 = r2 = m2*(100-i2)/20
LET m3 = m3 + m1
LET m4 = m4 + m2
GOSUB 3300
2790 u = 0: u2 = 0
PRINT "---------------"
GOTO 620
'finish off
2830 PRINT " The Confederacy has surrendered."
GOTO 2860
2850 PRINT " The Union has surrendered."
2860 PRINT
PRINT
PRINT
PRINT " The Confederacy has won "w" battles and lost "l
IF y = 5 THEN 2940
IF y2 = 5 THEN 2940
IF w<=l THEN 2940
IF y = 5 THEN 2940
PRINT " The Confederacy has won the war."
GOTO 2950
2940 PRINT " The Union has won the war."
2950 PRINT
IF r1 = 0 THEN 3100
PRINT " For the "w+l+wo" battles fought (excluding reruns)"
PRINT " "," "," ";
PRINT " Confederacy"," Union"
PRINT "Historical losses",INT (p1+0.5),INT (p2 + 0.5)
PRINT "Simulated losses",INT (t1 + 0.5),INT (t2 + 0.5)
PRINT
PRINT " % of original",INT (100*(t1/p1)+0.5),INT (100* (t2/p2)+0.5)
IF b$ = "yes" THEN 3100
PRINT
PRINT " Union Intelligence suggests that the South used"
PRINT "Strategies 1, 2, 3, 4 in the following percentages."
PRINT s(1);s(2);s(3);s(4)
'--------------------------------------------------------------
3100 STOP
3110 ' - Union strategy is Computer chosen
PRINT " Union Strategy is ";
IF a <> 0 THEN 3180
3140 INPUT y2
IF y2 <=0 THEN 3160
IF y2 < 5 THEN 3290
3160 PRINT " Enter 1, 2, 3, or 4 (usually previous Union strategy)"
GOTO 3140
3180 LET so = 0
LET r = 100*RND (0)
FOR i = 1 TO 4
LET so = so + s(i)
' if actual strategy is in data statements
' then r-100 is extra weight given to that strategy.
IF r<so THEN 3270
NEXT i
' if actual strategy is in then here is y2 = hist strategy
3270 LET y2 = i
PRINT y2
3290 RETURN
3300 ' learn present strategy, start forgetting old ones
' present strategy of South gains 3*s, others lose s
' probability points, unless a strategy falls below 5%.
LET s = 3
LET so = 0
FOR i = 1 TO 4
IF s(i) <= 5 THEN 3390
LET s(i) = s(i) - s
LET so = so + s
3390 NEXT i
LET s(y) = s(y) + so
RETURN
' Historical data...can add more (strat.,etc) by inserting
' Data statements after appro. info and adjusting read
DATA "Bull Run",18000,18500,1967,2708,1
DATA "Shiloh",40000.,44894.,10699,13047,3
DATA "Seven Days",95000.,115000.,20614,15849,3
DATA "Second Bull Run",54000.,63000.,10000,14000,2
DATA "Antietan",40000.,50000.,10000,12000,3
DATA "Fredericksburg",75000.,120000.,5377,12653,1
DATA "Murfreesboro",38000.,45000.,11000,12000,1
DATA "Chancellorsville",32000.,90000.,13000,17197,2
DATA "Vicksburg",50000.,70000.,12000,19000,1
DATA "Gettysburg",72500.,85000.,20000,23000,3
DATA "Chickamauga",66000.,60000.,18000,16000,2
DATA "Chattanooga",37000.,60000.,36700,5800,2
DATA "Spotsylvania",62000.,110000.,17723,18000,2
DATA "Atlanta",65000.,100000.,8500,3700,1
3580 PRINT " July 21, 1861. Gen. Beauregard, commanding the South, met
PRINT "Union forces with Gen. McDowell in a premature battle at"
PRINT "Bull Run. Gen Jackson helped push back the Union attack."
GOTO 1150
3620 PRINT " Apreil 6-7, 1862. The Confederate surprise attack at"
PRINT "Shiloh failed due to poor organization."
GOTO 1150
3650 PRINT " June 25 - July 1, 1862. General Lee (CSA) upheld the"
PRINT "offensive throughout the battle and forced Gen. Mc Lellan"
PRINT "and the Union forces away from Richmond."
GOTO 1150
3690 PRINT " Aug. 29-30, 1862. The combined Confederate forces under"
PRINT "Lee and Jackson drove the Union forces back into Washington."
GOTO 1150
3720 PRINT " Sept 17, 1862. The South failed to incorporate Maryland"
PRINT "into thre Confederacy."
GOTO 1150
3750 PRINT " Dec. 13, 1862. The Confederacy under Lee sucessfully"
PRINT "repulsed an attack by the Union under Gen. Burnside."
GOTO 1150
3780 PRINT " Dec. 31, 1862. The South under Gen. Bragg won a close battle."
GOTO 1150
3800 PRINT " May 1-6, 1863. The South had a costly victory and lost
PRINT "one of their outstanding Generals, `Stonewall' Jackson."
GOTO 1150
3830 PRINT " July 4, 1863. Vicksburg was a costly defeat for the South"
PRINT "because it gave the Union access to the Mississippi."
GOTO 1150
3860 PRINT " July 1-3, 1863. A Southern mistake by Gen. Lee at Gettysburg"
PRINT "cost them one of the most crucial battles of the war."
GOTO 1150
3890 PRINT " Sept. 15, 1863. Confusion in a forest near Chickamauga led"
PRINT "to a costly Southern victory."
GOTO 1150
3920 PRINT " Nov. 25, 1863. After the South had sieged Gen. Rosencrans'"
PRINT "army for three months, Gen. Grant broke the siege."
GOTO 1150
3950 PRINT " May 5, 1864. Grant's plan to keep Lee isolated began to"
PRINT "fail here, and continued at Cold Harbor and Petersburg."
GOTO 1150
3980 PRINT " August, 1864. Sherman and three veteran armies converged"
PRINT "on Atlanta and dealt the death blow to the Confederacy."
GOTO 1150
SETSCREEN:
rgb 0,9,9,9 'paper
rgb 1,0,5,10'pen
rgb 2,13,0,0'field
rgb 3,15,15,0 'highlight
SUB rgb(n%,r%,g%,b%) STATIC
PALETTE n%,r%/16,g%/16,b%/16
END SUB
RETURN
END